package com.dormitory.myt.sushecontroller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dormitory.myt.common.R;
import com.dormitory.myt.en.Detail;
import com.dormitory.myt.service.DetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/detail")
@Slf4j
public class DetailContorller{
@Autowired
private DetailService detailServcie;
    @GetMapping
    public R<List<Detail> >xsxs1(HttpServletResponse response, @RequestParam Integer sushehao){
        response.setHeader("Access-Control-Allow-Origin","*");

        LambdaQueryWrapper<Detail> queryWrapper = new LambdaQueryWrapper<>();
        //根据宿舍来查询：
        queryWrapper.eq(Detail::getSushehao,sushehao);
        List<Detail> list = detailServcie.list(queryWrapper);
        return R.success(list);
    }
}
